package rule18;

import java.util.Collection;
import java.util.HashSet;

/**
 * @author ChangLiang
 * @date 2020/3/17
 */
public class HashSetCounterV0 extends HashSet {

    private int count = 0;

    public HashSetCounterV0(){}

    public HashSetCounterV0(int init, float loadFactor) {
        super(init, loadFactor);
    }

    @Override
    public boolean add(Object object) {
        count++;
        return super.add(object);
    }

    @Override
    public boolean addAll(Collection collection) {
        count += collection.size();
        return super.addAll(collection);
    }

    public int getCount() {
        return count;
    }
}
